🎖️GitЯра🎖️
Node / meshtastic / Meshtastic-Android / files / core / service / src / androidHostTest / kotlin / org / meshtastic / core / service / ServiceBroadcastsTest.kt
Displaying Raw • Download
core/service/src/androidHostTest/kotlin/org/meshtastic/core/service/ServiceBroadcastsTest.kt renovate/net.java.dev.jna-jna-5.x (5a8f4966) Text, 5.12 KB
T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.core.service
Tff7b72import T7ee787android.app.Application
Tff7b72import T7ee787android.content.Context
Tff7b72import T7ee787androidx.test.core.app.ApplicationProvider
Tff7b72import T7ee787co.touchlab.kermit.Severity
Tff7b72import T7ee787kotlinx.coroutines.flow.Flow
Tff7b72import T7ee787kotlinx.coroutines.flow.MutableSharedFlow
Tff7b72import T7ee787kotlinx.coroutines.flow.MutableStateFlow
Tff7b72import T7ee787kotlinx.coroutines.flow.asFlow
Tff7b72import T7ee787org.junit.Before
Tff7b72import T7ee787org.junit.Test
Tff7b72import T7ee787org.junit.runner.RunWith
Tff7b72import T7ee787org.meshtastic.core.model.ConnectionState
Tff7b72import T7ee787org.meshtastic.core.model.service.ServiceAction
Tff7b72import T7ee787org.meshtastic.core.model.service.TracerouteResponse
Tff7b72import T7ee787org.meshtastic.core.repository.ServiceRepository
Tff7b72import T7ee787org.meshtastic.proto.ClientNotification
Tff7b72import T7ee787org.meshtastic.proto.MeshPacket
Tff7b72import T7ee787org.robolectric.RobolectricTestRunner
Tff7b72import T7ee787org.robolectric.Shadows.shadowOf
Tff7b72import T7ee787org.robolectric.annotation.Config
Tff7b72import T7ee787kotlin.test.assertEquals
Tf0883e@RunWithTb4b4b4(Te6edf3RobolectricTestRunnerTff7b72::Te6edf3classTb4b4b4)
Tf0883e@ConfigTb4b4b4(Te6edf3sdk Tff7b72= Tff7b72[T79c0ff3T79c0ff4Tff7b72]Tb4b4b4)
Tff7b72class T56d364ServiceBroadcastsTest Tb4b4b4{
Tff7b72private Tff7b72lateinit Tff7b72var Te6edf3contextTb4b4b4: Te6edf3Context
Tff7b72private Tff7b72val Te6edf3serviceRepository Tff7b72= Te6edf3FakeServiceRepositoryTb4b4b4(Tb4b4b4)
Tff7b72private Tff7b72lateinit Tff7b72var Te6edf3broadcastsTb4b4b4: Te6edf3ServiceBroadcasts
Tf0883e@Before
Tff7b72fun Td2a8ffsetUpTb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3context Tff7b72= Te6edf3ApplicationProviderTb4b4b4.Te6edf3getApplicationContextTb4b4b4(Tb4b4b4)
Te6edf3broadcasts Tff7b72= Te6edf3ServiceBroadcastsTb4b4b4(Te6edf3contextTb4b4b4, Te6edf3serviceRepositoryTb4b4b4)
Te6edf3serviceRepositoryTb4b4b4.Te6edf3setConnectionStateTb4b4b4(Te6edf3ConnectionStateTb4b4b4.Te6edf3ConnectedTb4b4b4)
Tb4b4b4}
Tf0883e@Test
Tff7b72fun Td2a8ff`broadcastConnection sends uppercase state string for ATAK`Tb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3broadcastsTb4b4b4.Te6edf3broadcastConnectionTb4b4b4(Tb4b4b4)
Tff7b72val Te6edf3shadowApp Tff7b72= Te6edf3shadowOfTb4b4b4(Te6edf3context Tff7b72as Te6edf3ApplicationTb4b4b4)
Tff7b72val Te6edf3intent Tff7b72= Te6edf3shadowAppTb4b4b4.Te6edf3broadcastIntentsTb4b4b4.Te6edf3find Tb4b4b4{ Tffa657itTb4b4b4.Te6edf3action Tff7b72=Tff7b72= Te6edf3ACTION_MESH_CONNECTED Tb4b4b4}
Te6edf3assertEqualsTb4b4b4(Ta5d6ff"Ta5d6ffCONNECTEDTa5d6ff"Tb4b4b4, Te6edf3intentTff7b72?.Te6edf3getStringExtraTb4b4b4(Te6edf3EXTRA_CONNECTEDTb4b4b4)Tb4b4b4)
Tb4b4b4}
Tf0883e@Test
Tff7b72fun Td2a8ff`broadcastConnection sends legacy connection intent`Tb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3broadcastsTb4b4b4.Te6edf3broadcastConnectionTb4b4b4(Tb4b4b4)
Tff7b72val Te6edf3shadowApp Tff7b72= Te6edf3shadowOfTb4b4b4(Te6edf3context Tff7b72as Te6edf3ApplicationTb4b4b4)
Tff7b72val Te6edf3intent Tff7b72= Te6edf3shadowAppTb4b4b4.Te6edf3broadcastIntentsTb4b4b4.Te6edf3find Tb4b4b4{ Tffa657itTb4b4b4.Te6edf3action Tff7b72=Tff7b72= Te6edf3ACTION_CONNECTION_CHANGED Tb4b4b4}
Te6edf3assertEqualsTb4b4b4(Ta5d6ff"Ta5d6ffCONNECTEDTa5d6ff"Tb4b4b4, Te6edf3intentTff7b72?.Te6edf3getStringExtraTb4b4b4(Te6edf3EXTRA_CONNECTEDTb4b4b4)Tb4b4b4)
Te6edf3assertEqualsTb4b4b4(Tff7b72trueTb4b4b4, Te6edf3intentTff7b72?.Te6edf3getBooleanExtraTb4b4b4(Ta5d6ff"Ta5d6ffconnectedTa5d6ff"Tb4b4b4, Tff7b72falseTb4b4b4)Tb4b4b4)
Tb4b4b4}
Tff7b72private Tff7b72class T56d364FakeServiceRepository Tb4b4b4: Te6edf3ServiceRepository Tb4b4b4{
Tff7b72override Tff7b72val Te6edf3connectionState Tff7b72= Te6edf3MutableStateFlowTff7b72<Te6edf3ConnectionStateTff7b72>Tb4b4b4(Te6edf3ConnectionStateTb4b4b4.Te6edf3DisconnectedTb4b4b4)
Tff7b72override Tff7b72val Te6edf3clientNotification Tff7b72= Te6edf3MutableStateFlowTff7b72<Te6edf3ClientNotification?Tff7b72>Tb4b4b4(Tff7b72nullTb4b4b4)
Tff7b72override Tff7b72val Te6edf3errorMessage Tff7b72= Te6edf3MutableStateFlowTff7b72<Tffa657String?Tff7b72>Tb4b4b4(Tff7b72nullTb4b4b4)
Tff7b72override Tff7b72val Te6edf3connectionProgress Tff7b72= Te6edf3MutableStateFlowTff7b72<Tffa657String?Tff7b72>Tb4b4b4(Tff7b72nullTb4b4b4)
Tff7b72private Tff7b72val Te6edf3meshPackets Tff7b72= Te6edf3MutableSharedFlowTff7b72<Te6edf3MeshPacketTff7b72>Tb4b4b4(Tb4b4b4)
Tff7b72override Tff7b72val Te6edf3meshPacketFlowTb4b4b4: Te6edf3FlowTff7b72<Te6edf3MeshPacketTff7b72> Tff7b72= Te6edf3meshPacketsTb4b4b4.Te6edf3asFlowTb4b4b4(Tb4b4b4)
Tff7b72override Tff7b72val Te6edf3tracerouteResponse Tff7b72= Te6edf3MutableStateFlowTff7b72<Te6edf3TracerouteResponse?Tff7b72>Tb4b4b4(Tff7b72nullTb4b4b4)
Tff7b72override Tff7b72val Te6edf3neighborInfoResponse Tff7b72= Te6edf3MutableStateFlowTff7b72<Tffa657String?Tff7b72>Tb4b4b4(Tff7b72nullTb4b4b4)
Tff7b72private Tff7b72val Te6edf3serviceActions Tff7b72= Te6edf3MutableSharedFlowTff7b72<Te6edf3ServiceActionTff7b72>Tb4b4b4(Tb4b4b4)
Tff7b72override Tff7b72val Te6edf3serviceActionTb4b4b4: Te6edf3FlowTff7b72<Te6edf3ServiceActionTff7b72> Tff7b72= Te6edf3serviceActions
Tff7b72override Tff7b72fun Td2a8ffsetConnectionStateTb4b4b4(Te6edf3connectionStateTb4b4b4: Te6edf3ConnectionStateTb4b4b4) Tb4b4b4{
Tff7b72thisTb4b4b4.Te6edf3connectionStateTb4b4b4.Te6edf3value Tff7b72= Te6edf3connectionState
Tb4b4b4}
Tff7b72override Tff7b72fun Td2a8ffsetClientNotificationTb4b4b4(Te6edf3notificationTb4b4b4: Te6edf3ClientNotification?Tb4b4b4) Tb4b4b4{
Te6edf3clientNotificationTb4b4b4.Te6edf3value Tff7b72= Te6edf3notification
Tb4b4b4}
Tff7b72override Tff7b72fun Td2a8ffclearClientNotificationTb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3clientNotificationTb4b4b4.Te6edf3value Tff7b72= Tff7b72null
Tb4b4b4}
Tff7b72override Tff7b72fun Td2a8ffsetErrorMessageTb4b4b4(Te6edf3textTb4b4b4: Tffa657StringTb4b4b4, Te6edf3severityTb4b4b4: Te6edf3SeverityTb4b4b4) Tb4b4b4{
Te6edf3errorMessageTb4b4b4.Te6edf3value Tff7b72= Te6edf3text
Tb4b4b4}
Tff7b72override Tff7b72fun Td2a8ffclearErrorMessageTb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3errorMessageTb4b4b4.Te6edf3value Tff7b72= Tff7b72null
Tb4b4b4}
Tff7b72override Tff7b72fun Td2a8ffsetConnectionProgressTb4b4b4(Te6edf3textTb4b4b4: Tffa657StringTb4b4b4) Tb4b4b4{
Te6edf3connectionProgressTb4b4b4.Te6edf3value Tff7b72= Te6edf3text
Tb4b4b4}
Tff7b72override Tff7b72suspend Tff7b72fun Td2a8ffemitMeshPacketTb4b4b4(Te6edf3packetTb4b4b4: Te6edf3MeshPacketTb4b4b4) Tb4b4b4{
Te6edf3meshPacketsTb4b4b4.Te6edf3emitTb4b4b4(Te6edf3packetTb4b4b4)
Tb4b4b4}
Tff7b72override Tff7b72fun Td2a8ffsetTracerouteResponseTb4b4b4(Te6edf3valueTb4b4b4: Te6edf3TracerouteResponse?Tb4b4b4) Tb4b4b4{
Te6edf3tracerouteResponseTb4b4b4.Te6edf3value Tff7b72= Te6edf3value
Tb4b4b4}
Tff7b72override Tff7b72fun Td2a8ffclearTracerouteResponseTb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3tracerouteResponseTb4b4b4.Te6edf3value Tff7b72= Tff7b72null
Tb4b4b4}
Tff7b72override Tff7b72fun Td2a8ffsetNeighborInfoResponseTb4b4b4(Te6edf3valueTb4b4b4: Tffa657String?Tb4b4b4) Tb4b4b4{
Te6edf3neighborInfoResponseTb4b4b4.Te6edf3value Tff7b72= Te6edf3value
Tb4b4b4}
Tff7b72override Tff7b72fun Td2a8ffclearNeighborInfoResponseTb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3neighborInfoResponseTb4b4b4.Te6edf3value Tff7b72= Tff7b72null
Tb4b4b4}
Tff7b72override Tff7b72suspend Tff7b72fun Td2a8ffonServiceActionTb4b4b4(Te6edf3actionTb4b4b4: Te6edf3ServiceActionTb4b4b4) Tb4b4b4{
Te6edf3serviceActionsTb4b4b4.Te6edf3emitTb4b4b4(Te6edf3actionTb4b4b4)
Tb4b4b4}
Tb4b4b4}
Tb4b4b4}
Served by rngit 1.5.0 - Generated in 0.06s